package cn.sx213.mongodb.service;

import cn.sx213.mongodb.config.MongoDbConfig;
import cn.sx213.mongodb.entity.Employee;
import cn.sx213.mongodb.repository.EmployeeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author liliang
 * @Description:
 * @Date 18/1/5 上午10:37
 */
@Service
public class EmployeeService {

    @Autowired
    private EmployeeRepository employeeRepository;

    public List<Employee> getEmployeeListByAge(int age) {
        return employeeRepository.getEmployeeByAge(age);
    }

    public Employee getEmployeeByName(String name) {
        return employeeRepository.getEmployeeByName(name);
    }

    public Employee getEmployee(Integer id) {
        return employeeRepository.findOne(id.toString());
    }

    public List<Employee> getEmployee(String name, int age) {
        List<Employee> employee = employeeRepository.getEmployeeByNameAndAge(name, age);
        return employee;
    }

}
